import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getx_simple_code/common/lang/translation_service.dart';
import 'package:getx_simple_code/common/routes/app_pages.dart';

Future<void> main() async {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  Locale getLanguageISOCode() {
    var locale;
    if(Get.deviceLocale?.scriptCode=='Hant'){
      locale = Locale('zh','HK');
    }else{
      locale = Get.deviceLocale;
    }
    return locale;
  }
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      debugShowCheckedModeBanner: false,
      initialRoute: AppPages.INITIAL,
      getPages: AppPages.routes,
      unknownRoute: AppPages.unknownRoute,
      navigatorObservers: [AppPages.observer],
      locale: getLanguageISOCode(),
      // locale: TranslationService.locale,
      fallbackLocale: TranslationService.fallbackLocale,
      translations: TranslationService(),
    );
  }
}